#!Makefile

CC = g++
CCFLAG = -g -Wno-deprecated -Wno-unused-variable
EXE_NAME = cit.exe

CSRC = main.cpp
COBJ = $(patsubst %.cpp, %.o, $(CSRC))

all: cit lit ass compiler


cit: $(EXE_NAME)

lit:
	@make CC="$(CC)" CFLAGS="$(CCFLAG)" -C lit

ass:
	@make CC="$(CC)" CFLAGS="$(CCFLAG)" -C ass

compiler:
	@make CC="$(CC)" CFLAGS="$(CCFLAG)" -C compiler

$(EXE_NAME): $(COBJ)
	$(CC) $^ -o $@ $(CCFLAGE)

%.o: %.cpp
	$(CC) $< -o $@ $(CCFLAGE) -c 

bin: ./bin
	@-mkdir bin

install: all bin
	cp $(EXE_NAME) ./bin
	@make -C lit install
	@make -C ass install
	@make -C compiler install
	
remove:
	rm -rf bin

.PHONY: cit lit ass compiler install remove cmake

clean:
	@rm -rf $(EXE_NAME) *.o CMakeFiles/ cmake_install.cmake CMakeCache.txt Makefile *.dSYM
	@make -C lit clean
	@make -C ass clean
	@make -C compiler clean


cmake:
	cmake .
	make -f Makefile


gitadd: clean remove
	@git add .
	@git commit -m "coding."

gitpush:
	@git push origin master

gitpull:
	@git pull origin master

over: gitadd gitpush